package com.huawei.hwid.c.a;

import android.content.Context;
import android.text.TextUtils;
import android.util.Xml;
import com.huawei.hwid.core.constants.HwAccountConstants;
import com.huawei.hwid.core.d.b.e;
import com.huawei.hwid.core.d.g;
import com.huawei.hwid.core.datatype.HwAccount;
import com.huawei.hwid.core.encrypt.c;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import org.xmlpull.v1.XmlSerializer;

public class b {
    private static void a(Context context, HwAccount hwAccount, boolean z, XmlSerializer xmlSerializer) throws IllegalStateException, IllegalArgumentException, IOException {
        if (hwAccount != null) {
            xmlSerializer.startTag("", HwAccountConstants.ACCOUNT_KEY);
            xmlSerializer.attribute("", "appId", hwAccount.c());
            String b = hwAccount.b();
            if (z) {
                b = c.b(context, b);
            }
            g.a(xmlSerializer, "accountName", b);
            b = hwAccount.d();
            if (z) {
                b = c.b(context, b);
            }
            g.a(xmlSerializer, "userId", b);
            b = hwAccount.i();
            if (z) {
                b = c.b(context, b);
            }
            String str = "deviceId";
            if (b == null) {
                b = "";
            }
            g.a(xmlSerializer, str, b);
            b = hwAccount.j();
            if (z) {
                b = c.b(context, b);
            }
            str = "subDeviceId";
            if (b == null) {
                b = "";
            }
            g.a(xmlSerializer, str, b);
            b = hwAccount.k();
            str = "deviceType";
            if (b == null) {
                b = "";
            }
            g.a(xmlSerializer, str, b);
            g.a(xmlSerializer, "serviceToken", c.b(context, hwAccount.g()));
            b = hwAccount.o();
            if (!TextUtils.isEmpty(b)) {
                if (z) {
                    b = c.b(context, b);
                }
                g.a(xmlSerializer, HwAccountConstants.EXTRA_AS_SERVER_DOMAIN, b);
            }
            b = hwAccount.p();
            if (!TextUtils.isEmpty(b)) {
                if (z) {
                    b = c.b(context, b);
                }
                g.a(xmlSerializer, HwAccountConstants.EXTRA_CAS_SERVER_DOMAIN, b);
            }
            g.a(xmlSerializer, "loginUserName", c.b(context, hwAccount.l()));
            g.a(xmlSerializer, "countryIsoCode", c.b(context, hwAccount.a()));
            b(context, hwAccount, z, xmlSerializer);
            xmlSerializer.endTag("", HwAccountConstants.ACCOUNT_KEY);
        }
    }

    private static void b(Context context, HwAccount hwAccount, boolean z, XmlSerializer xmlSerializer) throws IllegalStateException, IllegalArgumentException, IOException {
        g.a(xmlSerializer, "siteId", hwAccount.e() + "");
        String h = hwAccount.h();
        String str = "accountType";
        if (h == null) {
            h = "";
        }
        g.a(xmlSerializer, str, h);
        h = hwAccount.n();
        if (z) {
            h = c.b(context, h);
        }
        str = "serviceCountryCode";
        if (h == null) {
            h = "";
        }
        g.a(xmlSerializer, str, h);
        h = hwAccount.q();
        if (z) {
            h = c.b(context, h);
        }
        str = "uuid";
        if (h == null) {
            h = "";
        }
        g.a(xmlSerializer, str, h);
        h = hwAccount.o();
        if (!TextUtils.isEmpty(h)) {
            h = c.b(context, h);
        }
        str = HwAccountConstants.EXTRA_AS_SERVER_DOMAIN;
        if (TextUtils.isEmpty(h)) {
            h = "";
        }
        g.a(xmlSerializer, str, h);
        h = hwAccount.p();
        if (!TextUtils.isEmpty(h)) {
            h = c.b(context, h);
        }
        str = HwAccountConstants.EXTRA_CAS_SERVER_DOMAIN;
        if (TextUtils.isEmpty(h)) {
            h = "";
        }
        g.a(xmlSerializer, str, h);
        h = hwAccount.r();
        str = "lastUpdateTime";
        if (TextUtils.isEmpty(h)) {
            h = "";
        }
        g.a(xmlSerializer, str, h);
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    public static void a(android.content.Context r7, java.lang.String r8, java.util.List<com.huawei.hwid.core.datatype.HwAccount> r9, boolean r10) {
        /*
        r6 = 1;
        r0 = a(r9);
        if (r0 == 0) goto L_0x0015;
    L_0x0007:
        r0 = r0.isEmpty();
        if (r0 != 0) goto L_0x0015;
    L_0x000d:
        if (r9 == 0) goto L_0x0015;
    L_0x000f:
        r0 = r9.isEmpty();
        if (r0 == 0) goto L_0x001d;
    L_0x0015:
        r0 = "SDKAccountXmlImpl";
        r1 = "write accounts into file error";
        com.huawei.hwid.core.d.b.e.b(r0, r1, r6);
    L_0x001c:
        return;
    L_0x001d:
        r1 = android.util.Xml.newSerializer();
        r2 = new java.io.StringWriter;
        r2.<init>();
        r1.setOutput(r2);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = "UTF-8";
        r3 = 1;
        r3 = java.lang.Boolean.valueOf(r3);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1.startDocument(r0, r3);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = "";
        r3 = "accounts";
        r1.startTag(r0, r3);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = "";
        r3 = "size";
        r4 = new java.lang.StringBuilder;	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r4.<init>();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r5 = r9.size();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r4 = r4.append(r5);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r5 = "";
        r4 = r4.append(r5);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r4 = r4.toString();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1.attribute(r0, r3, r4);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r3 = r9.iterator();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
    L_0x005c:
        r0 = r3.hasNext();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        if (r0 == 0) goto L_0x0082;
    L_0x0062:
        r0 = r3.next();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = (com.huawei.hwid.core.datatype.HwAccount) r0;	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        a(r7, r0, r10, r1);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        goto L_0x005c;
    L_0x006c:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IllegalArgumentException write accounts failed!";
        r3 = 1;
        com.huawei.hwid.core.d.b.e.d(r0, r1, r3);	 Catch:{ all -> 0x013b }
        r2.close();	 Catch:{ IOException -> 0x0079 }
        goto L_0x001c;
    L_0x0079:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r0, r1, r6);
        goto L_0x001c;
    L_0x0082:
        r0 = "";
        r3 = "accounts";
        r1.endTag(r0, r3);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1.endDocument();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = new java.lang.StringBuilder;	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0.<init>();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1 = r7.getFilesDir();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1 = r1.getAbsolutePath();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = r0.append(r1);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1 = "/";
        r0 = r0.append(r1);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = r0.toString();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1 = r2.toString();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1 = com.huawei.hwid.core.d.b.d(r1);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = com.huawei.hwid.core.d.g.a(r0, r8, r1);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r1 = "SDKAccountXmlImpl";
        r3 = new java.lang.StringBuilder;	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r3.<init>();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r4 = "write accounts into file :";
        r3 = r3.append(r4);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = r3.append(r0);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r0 = r0.toString();	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r3 = 1;
        com.huawei.hwid.core.d.b.e.b(r1, r0, r3);	 Catch:{ IllegalArgumentException -> 0x006c, IllegalStateException -> 0x00db, IOException -> 0x00f3, RuntimeException -> 0x010b, Exception -> 0x0123 }
        r2.close();	 Catch:{ IOException -> 0x00d1 }
        goto L_0x001c;
    L_0x00d1:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r0, r1, r6);
        goto L_0x001c;
    L_0x00db:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IllegalStateException write accounts failed!";
        r3 = 1;
        com.huawei.hwid.core.d.b.e.d(r0, r1, r3);	 Catch:{ all -> 0x013b }
        r2.close();	 Catch:{ IOException -> 0x00e9 }
        goto L_0x001c;
    L_0x00e9:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r0, r1, r6);
        goto L_0x001c;
    L_0x00f3:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException write accounts failed!";
        r3 = 1;
        com.huawei.hwid.core.d.b.e.d(r0, r1, r3);	 Catch:{ all -> 0x013b }
        r2.close();	 Catch:{ IOException -> 0x0101 }
        goto L_0x001c;
    L_0x0101:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r0, r1, r6);
        goto L_0x001c;
    L_0x010b:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "RuntimeException write accounts failed!";
        r3 = 1;
        com.huawei.hwid.core.d.b.e.d(r0, r1, r3);	 Catch:{ all -> 0x013b }
        r2.close();	 Catch:{ IOException -> 0x0119 }
        goto L_0x001c;
    L_0x0119:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r0, r1, r6);
        goto L_0x001c;
    L_0x0123:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "Exception write accounts failed!";
        r3 = 1;
        com.huawei.hwid.core.d.b.e.d(r0, r1, r3);	 Catch:{ all -> 0x013b }
        r2.close();	 Catch:{ IOException -> 0x0131 }
        goto L_0x001c;
    L_0x0131:
        r0 = move-exception;
        r0 = "SDKAccountXmlImpl";
        r1 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r0, r1, r6);
        goto L_0x001c;
    L_0x013b:
        r0 = move-exception;
        r2.close();	 Catch:{ IOException -> 0x0140 }
    L_0x013f:
        throw r0;
    L_0x0140:
        r1 = move-exception;
        r1 = "SDKAccountXmlImpl";
        r2 = "IOException ";
        com.huawei.hwid.core.d.b.e.d(r1, r2, r6);
        goto L_0x013f;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.hwid.c.a.b.a(android.content.Context, java.lang.String, java.util.List, boolean):void");
    }

    public static ArrayList<HwAccount> a(String str, Context context, boolean z) {
        ArrayList<HwAccount> a;
        Throwable th;
        InputStream inputStream = null;
        InputStream inputStream2 = null;
        try {
            File file = new File(context.getFilesDir().getAbsolutePath() + "/" + str);
            if (file.exists()) {
                inputStream2 = new FileInputStream(file);
                try {
                    XmlPullParser newPullParser = Xml.newPullParser();
                    newPullParser.setInput(inputStream2, null);
                    a = a(newPullParser, context, z);
                    if (inputStream2 != null) {
                        try {
                            inputStream2.close();
                        } catch (IOException e) {
                            e.d("SDKAccountXmlImpl", "IOException  ", true);
                        }
                    }
                } catch (XmlPullParserException e2) {
                    inputStream = inputStream2;
                    try {
                        e.d("SDKAccountXmlImpl", "XmlPullParserException read xml failed!", true);
                        a = new ArrayList();
                        if (inputStream != null) {
                            try {
                                inputStream.close();
                            } catch (IOException e3) {
                                e.d("SDKAccountXmlImpl", "IOException  ", true);
                            }
                        }
                        return a;
                    } catch (Throwable th2) {
                        th = th2;
                        if (inputStream != null) {
                            try {
                                inputStream.close();
                            } catch (IOException e4) {
                                e.d("SDKAccountXmlImpl", "IOException  ", true);
                            }
                        }
                        throw th;
                    }
                } catch (FileNotFoundException e5) {
                    inputStream = inputStream2;
                    e.d("SDKAccountXmlImpl", "FileNotFoundException read xml failed!", true);
                    a = new ArrayList();
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e6) {
                            e.d("SDKAccountXmlImpl", "IOException  ", true);
                        }
                    }
                    return a;
                } catch (IOException e7) {
                    inputStream = inputStream2;
                    e.d("SDKAccountXmlImpl", "IOException read xml failed!", true);
                    a = new ArrayList();
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e8) {
                            e.d("SDKAccountXmlImpl", "IOException  ", true);
                        }
                    }
                    return a;
                } catch (RuntimeException e9) {
                    inputStream = inputStream2;
                    e.d("SDKAccountXmlImpl", "RuntimeException read xml failed!", true);
                    a = new ArrayList();
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e10) {
                            e.d("SDKAccountXmlImpl", "IOException  ", true);
                        }
                    }
                    return a;
                } catch (Exception e11) {
                    inputStream = inputStream2;
                    e.d("SDKAccountXmlImpl", "Exception read xml failed!", true);
                    a = new ArrayList();
                    if (inputStream != null) {
                        try {
                            inputStream.close();
                        } catch (IOException e12) {
                            e.d("SDKAccountXmlImpl", "IOException  ", true);
                        }
                    }
                    return a;
                } catch (Throwable th3) {
                    th = th3;
                    inputStream = inputStream2;
                    if (inputStream != null) {
                        inputStream.close();
                    }
                    throw th;
                }
            }
            e.a("SDKAccountXmlImpl", " sdk filepath not exist", true);
            a = new ArrayList();
            if (null != null) {
                try {
                    inputStream2.close();
                } catch (IOException e13) {
                    e.d("SDKAccountXmlImpl", "IOException  ", true);
                }
            }
        } catch (XmlPullParserException e14) {
            e.d("SDKAccountXmlImpl", "XmlPullParserException read xml failed!", true);
            a = new ArrayList();
            if (inputStream != null) {
                inputStream.close();
            }
            return a;
        } catch (FileNotFoundException e15) {
            e.d("SDKAccountXmlImpl", "FileNotFoundException read xml failed!", true);
            a = new ArrayList();
            if (inputStream != null) {
                inputStream.close();
            }
            return a;
        } catch (IOException e16) {
            e.d("SDKAccountXmlImpl", "IOException read xml failed!", true);
            a = new ArrayList();
            if (inputStream != null) {
                inputStream.close();
            }
            return a;
        } catch (RuntimeException e17) {
            e.d("SDKAccountXmlImpl", "RuntimeException read xml failed!", true);
            a = new ArrayList();
            if (inputStream != null) {
                inputStream.close();
            }
            return a;
        } catch (Exception e18) {
            e.d("SDKAccountXmlImpl", "Exception read xml failed!", true);
            a = new ArrayList();
            if (inputStream != null) {
                inputStream.close();
            }
            return a;
        }
        return a;
    }

    private static void a(XmlPullParser xmlPullParser, Context context, boolean z, HwAccount hwAccount, String str) throws XmlPullParserException, IOException {
        String nextText;
        if ("deviceId".equals(str)) {
            nextText = xmlPullParser.nextText();
            if (z) {
                nextText = c.c(context, nextText);
            }
            hwAccount.h(nextText);
        } else if ("subDeviceId".equals(str)) {
            nextText = xmlPullParser.nextText();
            if (z) {
                nextText = c.c(context, nextText);
            }
            hwAccount.i(nextText);
        } else if ("deviceType".equals(str)) {
            hwAccount.j(xmlPullParser.nextText());
        } else if ("serviceToken".equals(str)) {
            hwAccount.f(c.c(context, xmlPullParser.nextText()));
        } else if ("siteId".equals(str)) {
            try {
                hwAccount.a(Integer.parseInt(xmlPullParser.nextText()));
            } catch (NumberFormatException e) {
                e.c("SDKAccountXmlImpl", "NumberFormatException: read accounts.xml parseInt error", true);
            } catch (Exception e2) {
                e.c("SDKAccountXmlImpl", "sdk read accounts.xml parseInt error", true);
            }
        } else if ("accountType".equals(str)) {
            hwAccount.g(xmlPullParser.nextText());
        } else {
            b(xmlPullParser, context, z, hwAccount, str);
        }
    }

    private static void b(XmlPullParser xmlPullParser, Context context, boolean z, HwAccount hwAccount, String str) throws XmlPullParserException, IOException {
        String nextText;
        if ("loginUserName".equals(str)) {
            nextText = xmlPullParser.nextText();
            if (z) {
                nextText = c.c(context, nextText);
            }
            hwAccount.k(nextText);
        } else if ("countryIsoCode".equals(str)) {
            nextText = xmlPullParser.nextText();
            if (z) {
                nextText = c.c(context, nextText);
            }
            hwAccount.a(nextText);
        } else if ("serviceCountryCode".equals(str)) {
            nextText = xmlPullParser.nextText();
            if (z) {
                nextText = c.c(context, nextText);
            }
            hwAccount.m(nextText);
        } else if ("uuid".equals(str)) {
            nextText = xmlPullParser.nextText();
            if (z) {
                nextText = c.c(context, nextText);
            }
            hwAccount.p(nextText);
        } else if (HwAccountConstants.EXTRA_AS_SERVER_DOMAIN.equals(str)) {
            nextText = c.c(context, xmlPullParser.nextText());
            if (!com.huawei.hwid.core.d.b.a(nextText)) {
                nextText = "";
            }
            hwAccount.n(nextText);
        } else if (HwAccountConstants.EXTRA_CAS_SERVER_DOMAIN.equals(str)) {
            nextText = c.c(context, xmlPullParser.nextText());
            if (!com.huawei.hwid.core.d.b.a(nextText)) {
                nextText = "";
            }
            hwAccount.o(nextText);
        }
    }

    /* JADX WARNING: inconsistent code. */
    /* Code decompiled incorrectly, please refer to instructions dump. */
    private static java.util.ArrayList<com.huawei.hwid.core.datatype.HwAccount> a(org.xmlpull.v1.XmlPullParser r6, android.content.Context r7, boolean r8) throws org.xmlpull.v1.XmlPullParserException, java.io.IOException {
        /*
        r4 = 1;
        r0 = "SDKAccountXmlImpl";
        r1 = "sdkaccount xml parseAccountsFromXml Start";
        com.huawei.hwid.core.d.b.e.b(r0, r1, r4);
        r0 = r6.getEventType();
        r2 = new java.util.ArrayList;
        r2.<init>();
        r1 = new com.huawei.hwid.core.datatype.HwAccount;
        r1.<init>();
    L_0x0016:
        if (r4 == r0) goto L_0x009b;
    L_0x0018:
        r3 = r6.getName();
        switch(r0) {
            case 0: goto L_0x0028;
            case 1: goto L_0x001f;
            case 2: goto L_0x0042;
            case 3: goto L_0x002a;
            default: goto L_0x001f;
        };
    L_0x001f:
        r0 = r1;
    L_0x0020:
        r1 = r6.next();
        r5 = r0;
        r0 = r1;
        r1 = r5;
        goto L_0x0016;
    L_0x0028:
        r0 = r1;
        goto L_0x0020;
    L_0x002a:
        r0 = "account";
        r0 = r0.equals(r3);
        if (r0 == 0) goto L_0x001f;
    L_0x0032:
        r0 = "SDKAccountXmlImpl";
        r3 = "parseAccountsFromXml add account:";
        com.huawei.hwid.core.d.b.e.b(r0, r3, r4);
        r2.add(r1);
        r0 = new com.huawei.hwid.core.datatype.HwAccount;
        r0.<init>();
        goto L_0x0020;
    L_0x0042:
        r0 = "account";
        r0 = r0.equals(r3);
        if (r0 == 0) goto L_0x0068;
    L_0x004a:
        r0 = "";
        r3 = "appId";
        r0 = r6.getAttributeValue(r0, r3);
        r3 = android.text.TextUtils.isEmpty(r0);
        if (r3 == 0) goto L_0x0063;
    L_0x0058:
        r0 = "SDKAccountXmlImpl";
        r3 = "sdk authTokenType is null";
        com.huawei.hwid.core.d.b.e.e(r0, r3, r4);
        r0 = com.huawei.hwid.core.d.b.c(r7);
    L_0x0063:
        r1.c(r0);
        r0 = r1;
        goto L_0x0020;
    L_0x0068:
        r0 = "accountName";
        r0 = r0.equals(r3);
        if (r0 == 0) goto L_0x007f;
    L_0x0070:
        r0 = r6.nextText();
        if (r8 == 0) goto L_0x007a;
    L_0x0076:
        r0 = com.huawei.hwid.core.encrypt.c.c(r7, r0);
    L_0x007a:
        r1.b(r0);
        r0 = r1;
        goto L_0x0020;
    L_0x007f:
        r0 = "userId";
        r0 = r0.equals(r3);
        if (r0 == 0) goto L_0x0096;
    L_0x0087:
        r0 = r6.nextText();
        if (r8 == 0) goto L_0x0091;
    L_0x008d:
        r0 = com.huawei.hwid.core.encrypt.c.c(r7, r0);
    L_0x0091:
        r1.d(r0);
        r0 = r1;
        goto L_0x0020;
    L_0x0096:
        a(r6, r7, r8, r1, r3);
        r0 = r1;
        goto L_0x0020;
    L_0x009b:
        return r2;
        */
        throw new UnsupportedOperationException("Method not decompiled: com.huawei.hwid.c.a.b.a(org.xmlpull.v1.XmlPullParser, android.content.Context, boolean):java.util.ArrayList<com.huawei.hwid.core.datatype.HwAccount>");
    }

    private static List<HwAccount> a(List<HwAccount> list) {
        if (list == null || list.isEmpty()) {
            return null;
        }
        Collection arrayList = new ArrayList();
        for (HwAccount hwAccount : list) {
            if (!com.huawei.hwid.core.d.b.a(hwAccount)) {
                arrayList.add(hwAccount);
            }
        }
        try {
            if (arrayList.isEmpty() || !list.containsAll(arrayList)) {
                return list;
            }
            list.removeAll(arrayList);
            return list;
        } catch (Exception e) {
            e.d("SDKAccountXmlImpl", "Exception", true);
            return list;
        }
    }
}
